<style>
    .ptu{
        min-height: 77px;
        max-height: 77px;
    }
</style>
    <div class="content margin_top_foot">
        <div class="searchbar fixed_top bg_mx_green white"></div>
        <div class="refresh_content">
            <div class="pull_refresh">
                <div class="margin_b_10 padding_10_15 bg_white flex text_center types" style="overflow-x: auto"></div>
                <div class="margin_b_10 bg_white pros"></div>
            </div>
            <div class="refresh_load"><div class="refresh_pull_arrow"></div></div>
        </div>
        <div class="sidebar fixed lineheight_4 white hide"></div>
        <footer class="foot_tab fixed_bottom mx_green font_16"></footer>
    </div>
    <div class="toast"></div>
    <!-- toast模版 -->
    <script type="text/template" charset="utf-8" id='toast_template'>
        <i class="iconfont icon-toast{{=it.icon}}"></i>
        <div class="toast_text">{{=it.text}}</div>
    </script>
    <script type="text/template" charset="utf-8" id='nav_template'></script>
    <script type="text/template" charset="utf-8" id='types_template'>
        {{for(var i=0;i<it.length;i++){}}
        <div class="flex_1" style="margin-right: 10px;">
            <div class="width_70 block_center circle">
                <a href="{{=it[i].url}}"><img src="{{=it[i].img}}" alt="" style="border-radius: 50%;width: 50px;height: 50px;"></a>
            </div>
            <div class="mx_green lineheight_3">{{=it[i].name}}</div>
        </div>
        {{}}}
    </script>
    <script type="text/template" charset="utf-8" id='pros_template'>
        {{for(var i=0;i<it.length;i++){}}
        <div class="border_b padding_h_15" onclick="location.href='{{=it[i].url}}'">
            <div class="lineheight_2 border_b">编号:{{=it[i].no}}</div>
            <div class="flex padding_v_15 light font_12">
                <div class="width_100">
                    <img class="ptu" src="{{=it[i].img}}" alt="">
                </div>
                <div class="left_200 padding_l_10">
                    <div class="">预出栏：{{=it[i].planout}}</div>
                    <div class="">批次：{{=it[i].title}}</div>
                    <div class="">价格：{{=it[i].price}}</div>
                    <div class="">品种：{{=it[i].varname}}</div>
                </div>
                <div class="width_100 padding_l_15 flex_center">
                    {{if(it[i].lingperson==0){}}
                    <div class="btn btn_danger font_14" style="">认养</div>
                    {{}else{}}
                    <div class="btn btn_default font_14" style="">已被认养</div>
                    {{}}}
                </div>
            </div>
        </div>
        {{}}}
    </script>
    <input name="_csrf" type="hidden" id="_csrf" value="<{$app->request->csrfToken}>">
    <script>
        // 页面初始化
            var evaltypes = doT.template($("#types_template").text());
            var evalpros = doT.template($("#pros_template").text());
            var evalToast = doT.template($("#toast_template").text());
            loadsearchbar(function(){
                $(".header_usercenter").show().next().hide()
            });
            var navs = <{$variety}>;
            loadsidenav(navs)
            var types = <{$variety}>;
            loaddata(".types",evaltypes,types);
            var pros = <{$pigs}>;
            loaddata(".pros",evalpros,pros);
            loadfootbar();
        // 搜索
            $(".content").on("input",".searchbar_input input",function(){
                var that = this;
                var keywords = $(this).val();
                if(keywords){
                    $.post("/shop/rasing/search-pig",{vid:<{$vid}>,keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                        if(res.status && res.status == 1){
                            toast("attention",res.msg)
                        }else{
                            $(".pros").html(evalpros(res))
                        }
                     },"json")
                }
            })
            function search(obj){
                var keywords = $(obj).next().val();
                if(keywords){
                    $.post("/shop/rasing/search-pig",{vid:<{$vid}>,keywords:keywords,_csrf:$('#_csrf').val()},function(res){
                        if(res.status && res.status == 1){
                            toast("attention",res.msg)
                        }else{
                            $(".pros").html(evalpros(res))
                        }
                     },"json")
                }else{
                    toast("attention","请输入搜索关键词",function(){
                        $(obj).next().focus()
                    });
                }
            }
        // 下拉加载更多
            var pindex = 1;
            var pullRefresh = new mobileRefresh({
                container: document.querySelector('.refresh_content'),
                triggerDistance: 100,
                type:"up"
            },function(){
                $.post("/shop/rasing/load-more",{vid:<{$vid}>,pindex:++pindex,_csrf:$('#_csrf').val()},function(res){
                    $(".pros").append(evalpros(res));
                    pullRefresh.cancelLoading();
                },"json")
            })
    </script>


